package leetcode_acm.leetcode_1;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年03月17日 12:44
 */
public class RightSideView {
    private class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
    }
    private List<Integer> list;
    public List<Integer> rightSideView(TreeNode root) {
        if(root == null){
            return Collections.emptyList();
        }
        list = new LinkedList<>();
        traversal(root,0);
        return list;
    }
    private void traversal(TreeNode root,int depth){
        if(root == null){
            return;
        }
        if(depth == list.size()){
            list.add(root.val);
        }
        traversal(root.right,depth+1);
        traversal(root.left,depth+1);
    }
}
